<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="/plug/layui/css/layui.css" rel="stylesheet">
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        body {
            padding: 16px;
        }
    </style>
</head>
<body>
<button type="button" class="layui-btn layui-btn-primary" id="add">
    <i class="layui-icon layui-icon-addition"></i> 添加账号
</button>

<table id="demo" lay-filter="test"></table>

<script src="/plug/layui/layui.js"></script>

<script type="text/html" id="barDemo">
    <div class="layui-btn-group">
        <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="edit"><i class="layui-icon layui-icon-edit"></i></a>
        <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
    </div>
</script>

<script>
    layui.use('table', function () {
        layui.jquery("#add").click(function () {
            window.open("/pc/index/add/");
        });
        layui.table.render({
            elem: '#demo'
            , url: '/api/account/sel' //数据接口
            , cols: [[ //表头
                {field: 'account_id', title: 'ID', sort: true},
                {field: 'account_no', title: '学号'},
                {field: 'account_name', title: '姓名'},
                {field: 'gender_name', title: '性别'},
                {field: 'add_time_name', title: '添加时间'},
                {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 88}
            ]]
        });
        layui.table.on('tool(test)', function (obj) {
            if (obj.event === 'edit') {
                window.open("/pc/index/edit?account_id=" + obj.data.account_id);
            }
        });
    });
</script>
</body>
</html>

